<?php
class SecurityException extends Exception{

	private $emailBody = null;
	private $userMessage = null;

	public function __construct($message=null,$code=null,$userMsg=null){
		parent::__construct($message,$code);
		$this->userMessage = $userMsg;
	}

	public function getReportAsEmail(){
		$body = "<h2>Potential Hack Attempt: \"{$this->getMessage()}\"</h2>";
		$body .= "<h3>File: {$this->getFile()} - Line: {$this->getLine()}</h3>";
		$body .= "<h3>IP Address: ".htmlentities($_SERVER['REMOTE_ADDR'])." - Request URI: ".htmlentities($_SERVER['REQUEST_URI'])."</h3>";
		global $my;
		if($my->id){
			$body .= "<h3>User ID: $my->id - Username: ".htmlentities($my->username)."</h3>";
		}
		$body .= "<pre>Request:".print_r($_REQUEST,true)."</pre>";
		$body .= "<pre>Get:".print_r($_GET,true)."</pre>";
		$body .= "<pre>Post:".print_r($_POST,true)."</pre>";
		$body .= "<pre>Server:".print_r($_SERVER,true)."</pre>";
		$body .= "<pre>User:".print_r(MhtmlCore::getUser(),true)."</pre>";
		$this->emailBody = $body;
		return $this->emailBody;
	}

	public function getUserMessage(){
		return $this->userMessage;
	}
}
?>